<html>
    <head>
        <meta charset="UTF-8">
        <title>Express Checkout</title>
        <link href="css/bootstrap.css" rel="stylesheet" type="text/css" />
        <script src="js/bootstrap.min.js"></script>
        <script src="js/div.js"></script>
    </head>
    <body>
        <?php
        session_start();

        $nvp = array(
            'TOKEN' => $_SESSION['TOKEN'],
            'METHOD' => 'GetExpressCheckoutDetails',
            'VERSION' => '108.0',
            'PWD' => $_SESSION['PWD'],
            'USER' => $_SESSION['USER'],
            'SUBJECT' => $_SESSION['SUBJECT'],
            'SIGNATURE' => $_SESSION['SIGNATURE']
        );

        $curl = curl_init();

        curl_setopt($curl, CURLOPT_URL, $_SESSION['ENDPOINT']);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($nvp));

        $response = urldecode(curl_exec($curl));

        $responseNvp = array();

        curl_close($curl);

        if (preg_match_all('/(?<name>[^\=]+)\=(?<value>[^&]+)&?/', $response, $matches)) {
            foreach ($matches['name'] as $offset => $name) {
                $responseNvp[$name] = $matches['value'][$offset];
            }
        }

        echo "</br>";
        echo "GetExpressCheckout";
        echo "Request";
        echo "<pre>";
        print_r($nvp);
        echo"</pre>";
        echo '<p>Response</p>';
        echo '<pre>';
        print_r($responseNvp);
        echo '</pre>';
        ?>
    </body>
</html>